const app = getApp()
import util from '../../../../utils/util'
import {
  GetWringEventList
} from '../../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    grider_storge:'',
    num:'',
    lists:[],

    isEmpty: false, // 是否为空
    isBottom: false, // 是否无数据触底了
    isReachBtm: false, // 是否触发上拉加载
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let grider_storge = wx.getStorageSync('grider')

    this.setData({
      grider_storge,
      num:options.num,
      status: options.status
    })

    this.getList()
  },

  getList() { // 获取事件列表
    let that = this;
    let params = {
      vollege_id: app.globalData.vollege_id,
      grider_id: this.data.grider_storge.id,
      num: this.data.num,
      status: this.data.status
    }
    util.apiRequest(GetWringEventList, params, null).then(r => {
      console.log('预警事件列表：',r)
      if (r.data.data.length == 0){
        that.setData({
          isEmpty:true
        })
      }
      that.setData({
        lists:r.data.data
      })
    })
  },

  checkDetail(e) {
    let id = e.currentTarget.dataset.id;
    let cat_id = e.currentTarget.dataset.cat_id;
    let status = e.currentTarget.dataset.status;

    if (cat_id == 1) {
      wx.navigateTo({
        url: '/pages/grid/grider_feedback_detail/grider_feedback_detail?id=' + id + '&status=' + status,
      })
    } else {
      let ucid_name = e.currentTarget.dataset.ucid_name;
      wx.navigateTo({
        url: '/pages/grid/unresolvedDetail/unresolvedDetail?id=' + id + '&ucid_name=' + ucid_name + '&status=' + status + '&type=' + this.data.type
      })
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})